package domain.entities;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.util.*;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * ComiteEtica entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "comite_etica", catalog = "bms")
public class ComiteEtica implements java.io.Serializable {

    // Fields
    private Integer id;
    private Category category;
    private Centro site;
    private String name;
    private YesNo gcpCompliance;
    private Address address;

    private ECMeetingFrecuency ecMeetingFrecuency;
    private String otherECMeetingFrecuency;
    private String timelineSubmitDocumentEC;
    private TimeToProvideDocuments timeToProvideDocumentApprovals;
    private String otherTimeToProvideDocumentApprovals;

    private YesNo sopsWritten;
    private YesNo allSingedDatedStamped;
    private YesNo evaluateDocumentsInEnglish;
    private YesNo registered;

    private Date registerDateBA;
    private Integer numberBA;
    private Integer pageBA;
    private String bookBA;

    private Fee fee;

    private Date expirationDate;

    private List<ContactPerson> contactPersons = new ArrayList<ContactPerson>(0);
    private Set<ProtocoloCentro> protocoloCentros = new HashSet<ProtocoloCentro>(0);

    private String eclipseId;

    private String fileNameSop;
    private byte[] fileSop;

    private String fileNameSchedule;
    private byte[] fileSchedule;
    //	private String notification1stPatientZieher;   TODO:move?
    //	private Date enrollmentAuthorizationZieher;   TODO:move?
//	private Date finalReport;       TODO:move?
    //	private Date sentToMoh;                 TODO:move?
//	private String signAllPages;            TODO:move?
//	private String sivnotificationZieher;   TODO:move?
    //	private String hasListOfMembers;    TODO:move?
//	private Date inspectionZieherDate;      TODO:move?
//	private Date inspectionZieherResults;       TODO:move?
//	private Date listOfMembersDate;           TODO:move?
//	private String local;               TODO:move?
//	private String membersNotParticipating; TODO:move?
//	private String membersParticipating;     TODO:move?


    // Constructors

    /** default constructor */
    public ComiteEtica() {
    }

    /** minimal constructor */
    public ComiteEtica(Address address) {
        this.address = address;
    }

    /** full constructor */
    //TODO:...

    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name = "ADDRESSid", nullable = false)
    public Address getAddress() {
        return this.address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    @Column(name = "timelineSubmitDocumentEC")
    public String getTimelineSubmitDocumentEC() {
        return this.timelineSubmitDocumentEC;
    }

    public void setTimelineSubmitDocumentEC(String timelineSubmitDocumentEC) {
        this.timelineSubmitDocumentEC = timelineSubmitDocumentEC;
    }

    @Column(name = "name")
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "comiteEticas")
    public Set<ProtocoloCentro> getProtocoloCentros() {
        return this.protocoloCentros;
    }

    public void setProtocoloCentros(Set<ProtocoloCentro> protocoloCentros) {
        this.protocoloCentros = protocoloCentros;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "comiteEtica")
    @LazyCollection(LazyCollectionOption.FALSE)
    public List<ContactPerson> getContactPersons() {
        return contactPersons;
    }

    public void setContactPersons(List<ContactPerson> contactPersons) {
        this.contactPersons = contactPersons;
    }

    @Enumerated(EnumType.ORDINAL)
    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @OneToOne
    public Centro getSite() {
        return site;
    }

    public void setSite(Centro site) {
        this.site = site;
    }

    @Enumerated(EnumType.ORDINAL)
    public ECMeetingFrecuency getEcMeetingFrecuency() {
        return ecMeetingFrecuency;
    }

    public void setEcMeetingFrecuency(ECMeetingFrecuency ecMeetingFrecuency) {
        this.ecMeetingFrecuency = ecMeetingFrecuency;
    }

    @Column(name = "otherECMeetingFrecuency")
    public String getOtherECMeetingFrecuency() {
        return otherECMeetingFrecuency;
    }

    public void setOtherECMeetingFrecuency(String otherECMeetingFrecuency) {
        this.otherECMeetingFrecuency = otherECMeetingFrecuency;
    }

    @Enumerated(EnumType.ORDINAL)
    public TimeToProvideDocuments getTimeToProvideDocumentApprovals() {
        return timeToProvideDocumentApprovals;
    }

    public void setTimeToProvideDocumentApprovals(TimeToProvideDocuments timeToProvideDocumentApprovals) {
        this.timeToProvideDocumentApprovals = timeToProvideDocumentApprovals;
    }

    @Enumerated(EnumType.ORDINAL)
    public YesNo getSopsWritten() {
        return sopsWritten;
    }

    public void setSopsWritten(YesNo sopsWritten) {
        this.sopsWritten = sopsWritten;
    }

    @Enumerated(EnumType.ORDINAL)
    public YesNo getGcpCompliance() {
        return gcpCompliance;
    }

    public void setGcpCompliance(YesNo gcpCompliance) {
        this.gcpCompliance = gcpCompliance;
    }

    @Enumerated(EnumType.ORDINAL)
    public YesNo getAllSingedDatedStamped() {
        return allSingedDatedStamped;
    }

    public void setAllSingedDatedStamped(YesNo allSingedDatedStamped) {
        this.allSingedDatedStamped = allSingedDatedStamped;
    }

    @Enumerated(EnumType.ORDINAL)
    public YesNo getEvaluateDocumentsInEnglish() {
        return evaluateDocumentsInEnglish;
    }

    public void setEvaluateDocumentsInEnglish(YesNo evaluateDocumentsInEnglish) {
        this.evaluateDocumentsInEnglish = evaluateDocumentsInEnglish;
    }

    @Enumerated(EnumType.ORDINAL)
    public YesNo getRegistered() {
        return registered;
    }

    public void setRegistered(YesNo registered) {
        this.registered = registered;
    }

    @Column(name = "otherTimeToProvideDocumentApprovals")
    public String getOtherTimeToProvideDocumentApprovals() {
        return otherTimeToProvideDocumentApprovals;
    }

    public void setOtherTimeToProvideDocumentApprovals(String otherTimeToProvideDocumentApprovals) {
        this.otherTimeToProvideDocumentApprovals = otherTimeToProvideDocumentApprovals;
    }

    @OneToOne(cascade=CascadeType.ALL)
    public Fee getFee() {
        return fee;
    }

    public void setFee(Fee fee) {
        this.fee = fee;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "expirationDate", length = 10)
    public Date getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
    }


    public enum TimeToProvideDocuments{
        _1_week(0,"1 week"),
        _15_days(1,"15 days"),
        _3_weeks(2,"3 weeks"),
        _1_month(3,"1 month"),
        Other(10,"Other");


        private String desc;
        private Integer id;

        TimeToProvideDocuments(){
            this.id = -1;
            this.desc = "";
        }

        TimeToProvideDocuments(Integer id,String name){
            this.id = id;
            this.desc = name;
        }

        public String getDescription(){
            return this.desc;
        }

        public Integer getId() {
            return this.id;
        }

        public void setName(String name) {
            this.desc = name;
        }

        public void setId(Integer id) {
            this.id = id;
        }


    }

    public enum YesNo{
        _Yes(0,"Yes"),
        _No(1,"No");

        private String desc;
        private Integer id;

        YesNo(){
            this.id = -1;
            this.desc = "";
        }

        YesNo(Integer id,String name){
            this.id = id;
            this.desc = name;
        }

        public String getDescription(){
            return this.desc;
        }

        public Integer getId() {
            return this.id;
        }

        public void setName(String name) {
            this.desc = name;
        }

        public void setId(Integer id) {
            this.id = id;
        }

    }


    public enum ECMeetingFrecuency{
        Once_per_month(0,"Once per month"),
        Once_per_week(1,"Once per week"),
        Each_15_days(2,"Each 15 days"),
        When_needed(3,"When needed"),
        Other(10,"Other");

        private String desc;
        private Integer id;

        ECMeetingFrecuency(){
            this.id = -1;
            this.desc = "";
        }

        ECMeetingFrecuency(Integer id,String name){
            this.id = id;
            this.desc = name;
        }

        public String getDescription() {
            return this.desc;
        }

        public Integer getId() {
            return this.id;
        }


        public void setId(Integer id) {
            this.id = id;
        }

    }

    public enum Category {
        Institutional(0,"Institutional"),ExtraInstitutional(1,"Extra-Institutional");

        private String name;
        private Integer id;

        Category(){
            this.id = -1;
            this.name = "";
        }

        Category(Integer id,String name){
            this.id = id;
            this.name = name;
        }

        public String getName() {
            return this.name();
        }

        public void setName(String name) {
            this.name = name;
        }

        public Integer getId() {
            return this.id;
        }

        public void setId(Integer id) {
            this.id = id;
        }
    }

    @Column(name = "eclipseId")
    public String getEclipseId() {
        return this.eclipseId;
    }

    public void setEclipseId(String eclipseId) {
        this.eclipseId = eclipseId;
    }


    @Temporal(TemporalType.DATE)
    @Column(name = "registerDateBA" , length = 10)
    public Date getRegisterDateBA() {
        return registerDateBA;
    }

    public void setRegisterDateBA(Date registerDateBA) {
        this.registerDateBA = registerDateBA;
    }

    @Column(name = "numberBA")
    public Integer getNumberBA() {
        return numberBA;
    }

    public void setNumberBA(Integer numberBA) {
        this.numberBA = numberBA;
    }

    @Column(name = "pageBA")
    public Integer getPageBA() {
        return pageBA;
    }

    public void setPageBA(Integer pageBA) {
        this.pageBA = pageBA;
    }

    @Column(name = "bookBA")
    public String getBookBA() {
        return bookBA;
    }

    public void setBookBA(String bookBA) {
        this.bookBA = bookBA;
    }

    @Column(name = "file_name_sop")
    public String getFileNameSop() {
        return this.fileNameSop;
    }

    public void setFileNameSop(String fileNameSop) {
        this.fileNameSop = fileNameSop;
    }

    @Column(name = "file_name_schedule")
    public String getFileNameSchedule() {
        return this.fileNameSchedule;
    }

    public void setFileNameSchedule(String fileNameSchedule) {
        this.fileNameSchedule = fileNameSchedule;
    }

    @Column(name = "file_sop")
    public byte[] getFileSop() {
        return fileSop;
    }

    public void setFileSop(byte[] fileSop) {
        this.fileSop = fileSop;
    }

    @Column(name = "file_schedule")
    public byte[] getFileSchedule() {
        return fileSchedule;
    }

    public void setFileSchedule(byte[] fileSchedule) {
        this.fileSchedule = fileSchedule;
    }

    private IrbSop sop;

    @OneToOne(cascade = CascadeType.ALL, optional = true)
    public IrbSop getSop() {
        return sop;
    }

    public void setSop(IrbSop sop) {
        this.sop = sop;
    }
}